home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 167 / Issue 167 - Jan 2002 - DPCS0102.iso / january / PI70 / data1.cab / Common_E / seplugin / Rotator.usp / SCRIPT / ROTATOR.JS
Encoding:
Text File  |  2001-10-18  |  6.4 KB  |  205 lines

  1. function RotatorEffect_GetLayer(layer_name)
  2. {    if (document.all) return document.all[layer_name];
  3.     else if (document.layers) document.layers[layer_name];
  4.     else return null;
  5. }
  6. function RotatorEffect_SetTop(TopPos)
  7. {
  8.     var Me = this;
  9.  
  10.     if (document.all)
  11.         document.all[Me.target].style.posTop = TopPos;
  12.     else if (document.layers)
  13.         document.layers[Me.target].top    = TopPos;
  14. }
  15. function RotatorEffect_GetTop()
  16. {
  17.     var Me = this;
  18.     
  19.     if (document.all)
  20.         return document.all[Me.target].style.posTop;
  21.     else if (document.layers)
  22.         return document.layers[Me.target].top;
  23. }
  24. function RotatorEffect_ScrollTimer(target,cy)
  25. {    var Me = this;
  26.     var i;
  27.     var IsReset    = false;
  28.     if (this.num != 0) return;
  29.     if (Me.counter.poser && 0 == (Me.counter.poser % Me.ClipHeight))
  30.         IsReset = true;
  31.     if (Me.counter.Stop)
  32.     {    setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.DelayTime);         
  33.         return;
  34.     }
  35.     for (i = 0; i < this.counter.stack.length; i++)
  36.     {    var item = this.counter.stack[i];
  37.         item.ScrollText(item.target,cy);
  38.     }
  39.     if (0 == this.num)
  40.         this.counter.poser ++;
  41.     if (IsReset)
  42.         setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.RepeatDelay);
  43.     else
  44.         setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.DelayTime);                     
  45. }
  46. function RotatorEffect_ScrollText(target,cy)
  47. {    var Me = this;
  48.     var IsReset = false;
  49.     var IsSizing= false;
  50.     var text_attr = Me.text_attr.Clone();
  51.     var new_text;
  52.  
  53.     if (document.all)
  54.         CellHeight = document.all[target].offsetHeight;
  55.     else if (document.layers)
  56.         CellHeight = Me.ClipHeight;
  57.  
  58.     if (Me.GetTop() <= (Me.OrgTop - 2 * Me.ClipHeight))
  59.     {    factor         = (Me.counter.count > 1)? Me.counter.count - 2 : 0 ;
  60.         Me.YClip    = 0;
  61.         Me.ClipTop    = 0;
  62.         Me.ClipBottom    = 0;
  63.         Me.YOff        = 0;
  64.         Me.SetTop(Me.OrgTop + factor * Me.ClipHeight);
  65.     }
  66.     else 
  67.     {    if (Me.GetTop() <= (Me.OrgTop - Me.ClipHeight + 1))
  68.             Me.ClipTop = Me.ClipTop + cy;    
  69.         if (Me.GetTop() < (Me.OrgTop))
  70.             Me.ClipBottom= Me.ClipBottom + cy;
  71.     }
  72.     
  73.     if (Me.GetTop() < (Me.OrgTop) && Me.GetTop() >= (Me.OrgTop - Me.ClipHeight + 1))
  74.         IsSizing = true;
  75.     
  76.     NewClip = 'rect(' + Me.ClipTop + ' ' + Me.ClipRight + ' ' + Me.ClipBottom + ' ' + Me.ClipLeft + ')';
  77. //    Test
  78.     if (IsSizing)
  79.     {
  80.         switch(Me.GetTop() % 9) 
  81.         {
  82.         case 6:    case 7:    case 8:    text_attr.Size = text_attr.Size + 1;    break;
  83.         case 0:    case 1:    case 2:    text_attr.Size = text_attr.Size - 1;    break;
  84.         }
  85.     }
  86. //    Update New Text HTML
  87.     if (Me.text)
  88.         new_text = AddLink(BlinkTextBlock(Me.text,text_attr),Me.text_link);
  89. //    Update Layer
  90.     if (document.all)
  91.     {
  92.         if (1 == Me.First)
  93.         {
  94.             Me.First = 0;
  95.         //    document.all[target].style.posTop =document.all[target].offsetTop + Me.ClipHeight + Me.YOff; 
  96.             document.all[target].style.posTop =document.all[this.counter.target].offsetTop + Me.ClipHeight + Me.YOff; 
  97.             document.all[target].style.posLeft=document.all[this.counter.target].offsetLeft; 
  98.             Me.OrgTop    = document.all[target].style.posTop - Me.YOff;
  99.         }    
  100.  
  101.         document.all[target].style.posTop = document.all[target].style.posTop - cy;
  102.         document.all[target].style.clip      = NewClip;
  103.         if (Me.text)
  104.             document.all[target].innerHTML      = new_text;
  105.     }
  106.     else if (document.layers)
  107.     {
  108.         if (1 == Me.First)
  109.         {
  110.             Me.First     = 0;    
  111.             Me.OrgTop    = document.layers[target].top - Me.YOff;    
  112.         }
  113.         document.layers[target].top     = document.layers[target].top - cy;
  114.         document.layers[target].clip.top = Me.ClipTop;
  115.         document.layers[target].clip.bottom = Me.ClipBottom;
  116.  
  117.         if (Me.text)
  118.         {
  119.             document.layers[target].document.open()
  120.             document.layers[target].document.write(new_text);
  121.             document.layers[target].document.close();
  122.         }
  123.     }
  124. }
  125. function RotatorEffect_Init(target,target_NS,delay,YOff,ClipWidth,ClipHeight,text,text_link,text_color,text_face,text_size,RepeatTime)
  126. {    var Me = this;
  127.  
  128.     if (document.layers)
  129.     {
  130.         if (document.layers[target] == null)
  131.             Me.target    = target_NS;
  132.         else
  133.             Me.target    = target;    //target_NS ???;
  134.         document.layers[Me.target].top = document.layers[this.counter.target].top + ClipHeight + YOff;
  135.         document.layers[Me.target].left= document.layers[this.counter.target].left;
  136.     }
  137.     else if (document.all)
  138.     {
  139.         Me.target        = target;
  140.     //    document.all[target].style.posTop =document.all[this.counter.target].offsetTop + ClipHeight + YOff; 
  141.     //    document.all[target].style.posLeft=document.all[this.counter.target].offsetLeft; 
  142.     }
  143.           
  144.     Me.First        = 1;
  145.     Me.YOff            = YOff;
  146.     Me.YClip        = 1;
  147.     Me.ClipWidth    = ClipWidth;
  148.     Me.ClipHeight    = ClipHeight;
  149.     Me.ClipLeft        = 0;
  150.     Me.ClipRight    = ClipWidth;
  151.     Me.ClipTop        = 0;
  152.     Me.ClipBottom    = 0;
  153.     Me.DelayTime    = delay;
  154.     Me.RepeatDelay    = RepeatTime;
  155.     Me.Repeat         = true;
  156.     Me.text            = text;
  157.     Me.text_link    = text_link;
  158.     Me.text_attr    = new TextBlock();
  159.     Me.text_attr.UseTextColor = true;
  160.     Me.text_attr.UseFont    = true;
  161.     Me.text_attr.UseSize    = true;
  162.     Me.text_attr.TextColor    = text_color;
  163.     Me.text_attr.Font = text_face;
  164.     Me.text_attr.Size = text_size;
  165.         
  166.     setTimeout(Me.name + ".ScrollTimer('" + Me.target + "',1);",50);
  167. }
  168. function RotatorEffect_OnMouseOver(event)
  169. {    if (this.PauseOnOver) this.counter.Stop = true;
  170.     var target_layer = GetLayer(this.counter.target);
  171.     if (target_layer)
  172.         if (target_layer.onmouseover)
  173.             target_layer.onmouseover(event);
  174. }
  175. function RotatorEffect_OnMouseOut(event)
  176. {    if (this.PauseOnOver) this.counter.Stop = false;
  177.     var target_layer = GetLayer(this.counter.target);
  178.     if (target_layer)
  179.         if (target_layer.onmouseout)
  180.             target_layer.onmouseout(event);
  181. }
  182. function RotatorStack(target)
  183. {    this.count        = 0;
  184.     this.Stop        = false;
  185.     this.target        = target;
  186.     this.stack        = new Array;
  187.     this.poser        = 0;
  188. }
  189. function RotatorEffect(name,counter,IsPause)
  190. {  this.Init         = RotatorEffect_Init;
  191.    this.ScrollTimer    = RotatorEffect_ScrollTimer;
  192.    this.ScrollText     = RotatorEffect_ScrollText;
  193.    this.SetTop           = RotatorEffect_SetTop;
  194.    this.GetTop           = RotatorEffect_GetTop;
  195.    this.GetLayer    = RotatorEffect_GetLayer;
  196.    this.OnMouseOver    = RotatorEffect_OnMouseOver;
  197.    this.OnMouseOut    = RotatorEffect_OnMouseOut;
  198.    this.name        = name;
  199.    this.counter        = counter;
  200.    this.num            = this.counter.count;
  201.    this.PauseOnOver    = IsPause;
  202.    this.counter.count ++;
  203.    this.counter.stack[this.counter.stack.length] = this;
  204. }
  205.